﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace lucere.analysis
{
    /// <summary> 
    /// Stemmer, implementing the Porter Stemming Algorithm
    /// 
    /// The Stemmer class transforms a word into its root form.  The input
    /// word can be provided a character at time (by calling add()), or at once
    /// by calling one of the various stem(something) methods.
    /// </summary>
    public interface IPorterStemmer
    {
        /// <summary> Add a character to the word being stemmed.  When you are finished
        /// adding characters, you can call stem(void) to process the word.
        /// </summary>
        void Add(char ch);

        /// <summary> Returns a reference to a character buffer containing the results of
        /// the stemming process.  You also need to consult getResultLength()
        /// to determine the length of the result.
        /// </summary>
        char[] ResultBuffer { get; }

        /// <summary> Returns the length of the word resulting from the stemming process.</summary>
        int ResultLength { get; }


        /// <summary> reset() resets the stemmer so it can stem another word.  If you invoke
        /// the stemmer by calling add(char) and then stem(), you must call reset()
        /// before starting another word.
        /// </summary>
        void Reset();


        /// <summary>Stem the word placed into the Stemmer buffer through calls to add().
        /// Returns true if the stemming process resulted in a word different
        /// from the input.  You can retrieve the result with
        /// getResultLength()/getResultBuffer() or toString().
        /// </summary>
        bool Stem();

        /// <summary>Stem a word contained in a char[].  Returns true if the stemming process
        /// resulted in a word different from the input.  You can retrieve the
        /// result with getResultLength()/getResultBuffer() or toString().
        /// </summary>
        bool Stem(char[] word);

        /// <summary>Stem a word contained in a leading portion of a char[] array.
        /// Returns true if the stemming process resulted in a word different
        /// from the input.  You can retrieve the result with
        /// getResultLength()/getResultBuffer() or toString().
        /// </summary>
        bool Stem(char[] word, int wordLen);

        /// <summary>Stem a word contained in a portion of a char[] array.  Returns
        /// true if the stemming process resulted in a word different from
        /// the input.  You can retrieve the result with
        /// getResultLength()/getResultBuffer() or toString().
        /// </summary>
        bool Stem(char[] wordBuffer, int offset, int wordLen);

        bool Stem(int i0);

        /// <summary> Stem a word provided as a String.  Returns the result as a String.</summary>
        string Stem(string s);
    }
}
